<?php
/**
 * Created by PhpStorm.
 * User: thanatos
 * Date: 2017/11/29
 * Time: 下午5:13
 */

namespace frontend\models\search;


use Yii;
use common\models\Package;

/**
 * Class PackageSearch
 * @package frontend\models\search
 *
 * @property Package[] $packageList
 */
class PackageSearch extends Package{
    
    
    public function getPackageList()
    {
        // 查询当前人群下会员卡
        $models = Package::find()->where(['group_id' => Yii::$app->user->identity->group_id])->select(['package_id', 'package_name', 'group_id',Yii::$app->user->identity->getPackageGroup()])->all();
        // 对比会员年龄
        return $models;
        
    }
    
    public function getPriceByPackage($id)
    {
        $field = Yii::$app->user->identity->getPackageGroup();
        $model = Package::find()->where(['package_id' => $id])->select(['package_id', 'package_name', 'group_id',$field])->one();
        return $model->$field;
    }
    
}